package com.lm.activiti.boot.design_pattern.strategy.annotate;

import org.apache.commons.lang3.builder.EqualsBuilder;

import java.lang.annotation.Annotation;
import java.util.Objects;

/**
 * @author lm_jcf
 * @date 2020/6/23 16:14
 */
public class AttenHandlerTypeImpl implements AttenHandlerType {

    private String roleType;

    public AttenHandlerTypeImpl(String roleType) {
        this.roleType = roleType;
    }

    @Override
    public String roleType() {
        return roleType;
    }

    @Override
    public Class<? extends Annotation> annotationType() {
        return AttenHandlerType.class;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

//        if (o == null || getClass() != o.getClass()) return false;

        AttenHandlerType that = (AttenHandlerType) o;

        return new EqualsBuilder()
                .append(roleType, that.roleType())
                .isEquals();
    }

    @Override
    public int hashCode() {

        if (Objects.isNull(roleType)) {
            return 0;
        }

        return (127 * "roleType".hashCode()) ^ roleType.hashCode();

        /*return new HashCodeBuilder(17, 37)
                .append(roleType)
                .toHashCode();*/
    }
}
